from snail_fun import Snail
import logging
from pathlib import Path
import time
import handle_pump

# 配置日志
current_dir = Path(__file__).parent
logs_dir = current_dir / "logs"
logs_dir.mkdir(parents=True, exist_ok=True)
log_filename = logs_dir / f"log_{time.strftime('%Y%m%d_%H%M%S')}.log"

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(levelname)s - %(message)s",
    handlers=[
        logging.FileHandler(log_filename),  # 输出到文件
        logging.StreamHandler()  # 输出到控制台
    ]
)

# 初始化 Snail 实例
snail = Snail()
handle = handle_pump.PumpController()

if __name__ == "__main__":
    # # 设置速度(速度设置不要超过500)
    snail.pump.set_speed(speed=150)
    snail.pump.move_pump_to_zero()
    # 从3号空气管道抽取空气，依次排空所有管道
    snail.pump.set_speed(speed=1000)
    snail.pump.move_and_aspirate(volume=10000, port_number=2)
    snail.pump.move_and_dispense(volume=5000, port_number=1)
    snail.pump.move_and_dispense(volume=5000, port_number=3)
    snail.pump.set_speed(speed=1000)
    snail.pump.move_and_aspirate(volume=10000, port_number=2)
    snail.pump.move_and_dispense(volume=5000, port_number=4)
    snail.pump.move_and_dispense(volume=5000, port_number=5)
    snail.pump.set_speed(speed=1000)
    snail.pump.move_and_aspirate(volume=10000, port_number=2)
    snail.pump.move_and_dispense(volume=5000, port_number=6)
    snail.pump.move_and_dispense(volume=5000, port_number=7)
    snail.pump.set_speed(speed=1000)
    snail.pump.move_and_aspirate(volume=10000, port_number=2)
    snail.pump.move_and_dispense(volume=5000, port_number=8)
    snail.pump.move_and_dispense(volume=5000, port_number=9)
